VERSION 5.00
Object = "{8E27C92E-1264-101C-8A2F-040224009C02}#7.0#0"; "MSCAL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmIPD 
   BackColor       =   &H00FFFFFF&
   Caption         =   "IPD Shipments"
   ClientHeight    =   3420
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8175
   Icon            =   "frmIPD.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   3420
   ScaleWidth      =   8175
   StartUpPosition =   1  'CenterOwner
   Begin MSACAL.Calendar Calendar1 
      Height          =   255
      Left            =   1800
      TabIndex        =   8
      TabStop         =   0   'False
      Top             =   540
      Visible         =   0   'False
      Width           =   255
      _Version        =   524288
      _ExtentX        =   450
      _ExtentY        =   450
      _StockProps     =   1
      BackColor       =   16777215
      Year            =   2004
      Month           =   2
      Day             =   9
      DayLength       =   1
      MonthLength     =   2
      DayFontColor    =   0
      FirstDay        =   1
      GridCellEffect  =   1
      GridFontColor   =   10485760
      GridLinesColor  =   -2147483632
      ShowDateSelectors=   -1  'True
      ShowDays        =   -1  'True
      ShowHorizontalGrid=   -1  'True
      ShowTitle       =   0   'False
      ShowVerticalGrid=   -1  'True
      TitleFontColor  =   10485760
      ValueIsNull     =   -1  'True
      BeginProperty DayFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty GridFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty TitleFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   12.01
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.ComboBox cboIPDStatus 
      Height          =   315
      ItemData        =   "frmIPD.frx":1272
      Left            =   5340
      List            =   "frmIPD.frx":1282
      TabIndex        =   1
      Top             =   2400
      Width           =   1035
   End
   Begin VB.TextBox f24 
      Height          =   315
      Left            =   1800
      TabIndex        =   0
      Top             =   2400
      Width           =   1035
   End
   Begin VB.CommandButton cmdADDIPD 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "Add"
      Height          =   315
      Left            =   780
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   2940
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdDeleteIPD 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "Delete"
      Height          =   315
      Left            =   4380
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2940
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdConfirmIPD 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "Confirm"
      Height          =   315
      Left            =   2580
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   2940
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdClose 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Close"
      Height          =   315
      Left            =   6120
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   2940
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Add/Modify IPD Shipments"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   2055
      Left            =   180
      TabIndex        =   7
      Top             =   180
      Width           =   7815
      Begin MSDataGridLib.DataGrid grdIPD 
         Height          =   1515
         Left            =   180
         TabIndex        =   6
         Top             =   360
         Width           =   7455
         _ExtentX        =   13150
         _ExtentY        =   2672
         _Version        =   393216
         AllowUpdate     =   0   'False
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "Status:"
      Height          =   255
      Index           =   43
      Left            =   4560
      TabIndex        =   10
      Top             =   2460
      Width           =   555
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFFFFF&
      Caption         =   "Ship Date:"
      Height          =   255
      Index           =   44
      Left            =   840
      TabIndex        =   9
      Top             =   2460
      Width           =   855
   End
   Begin VB.Image Image1 
      Height          =   345
      Left            =   2940
      Picture         =   "frmIPD.frx":12A5
      Stretch         =   -1  'True
      Top             =   2400
      Width           =   345
   End
End
Attribute VB_Name = "frmIPD"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim m_rsIPD As New ADODB.Recordset     'Module level recordset tied to grdCommodities

Private Sub cboIPDStatus_Click()
    
    Call UpdateIPDGrid(cboIPDStatus, f24)
    
End Sub

Private Sub cmdADDIPD_Click()
    frmIPDAdd.Show vbModeless, Me
    frmIPDAdd.Caption = "IPD Create Shipment"
End Sub

Private Sub cmdClose_Click()
    Me.Hide
    frmShip.SetFocus
End Sub

Private Sub cmdConfirmIPD_Click()
    
    g_blnIPDConfirm = True
    frmIPDAdd.Show vbModeless, Me
    frmIPDAdd.Caption = "IPD Confirm Shipment"
    
End Sub

Private Sub cmdDeleteIPD_Click()
    
    g_blnIPD = True
    Call SendData(BuildIPDDeleteTrans)
    Call UpdateIPDGrid(cboIPDStatus, f24)

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Activate()
' DateTime  : 10/25/2004
' Purpose   : Call routine to load Commodities into datagrid whenever the form is the
'             active form.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Activate()
    On Error GoTo EH
    g_strErrorLocation = "frmIPD:Form_Activate"
        
    Call UpdateIPDGrid(cboIPDStatus, f24)
    
    f24.SetFocus
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Deactivate()
' DateTime  : 10/25/2004
' Purpose   : Closes module level recordset and sets it to nothing.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Deactivate()
    On Error GoTo EH
    g_strErrorLocation = "frmIPD:Form_Deactivate"
        
    If m_rsIPD.State = adStateOpen Then m_rsCommodities.Close
    Set m_rsIPD = Nothing
    
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub

Private Sub Form_Load()
    f24.Text = Date
    Calendar1.Today
    Calendar1.Height = 2295 'Ship date - Ship Tab
    Calendar1.Width = 3015
    cboIPDStatus = "Open"
    
End Sub

Private Sub grdIPD_Click()
    Call SetButtons
End Sub

'---------------------------------------------------------------------------------------
' Module    : Image1_Click()
' DateTime  : 10/25/2004
' Author    : Chris Elwell
' Purpose   : Show the ShipDate calendar
'---------------------------------------------------------------------------------------
'
Private Sub Image1_Click()
    Calendar1.Visible = True
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Calendar1_Click()
' DateTime  : 10/25/2004
' Purpose   : Puts date selected on calendar in ShipDate field and updates the IPD Grid.
'---------------------------------------------------------------------------------------
'
Private Sub Calendar1_DblClick()
    
    f24.Text = Calendar1.Value
    Calendar1.Visible = False
    Call UpdateIPDGrid(cboIPDStatus, f24)

End Sub

'---------------------------------------------------------------------------------------
' Procedure : UpdateIPDGrid()
' DateTime  : 10/25/2004
' Purpose   : Update the IPD grid and set column headings
' Call from : Form_Activate, cmdDelete_Click
'---------------------------------------------------------------------------------------
'
Public Sub UpdateIPDGrid(ByVal strIPDStatus As String, ByVal dteShipDate As Date)
    Dim strQuery As String
    
    On Error GoTo EH
    g_strErrorLocation = "frmIPD:UpdateIPDGrid"
    
    strQuery = "SELECT g_str1355,g_str1297,IPDStatus,g_str50,g_str29 FROM IPD Where MAWB = 1 And g_str10 = " & SingleQuotes(frmSetup.f10)
    
    Select Case strIPDStatus
        Case "ALL"
            strQuery = strQuery & " And g_str24 = #" & dteShipDate & "#"
        Case "Open"
            strQuery = strQuery & " And IPDStatus = 'Open' And g_str24 = #" & dteShipDate & "#"
        Case "Confirmed"
            strQuery = strQuery & " And IPDStatus = 'Confirmed' And g_str24 = #" & dteShipDate & "#"
        Case "Deleted"
            strQuery = strQuery & " And IPDStatus = 'Deleted' And g_str24 = #" & dteShipDate & "#"
    End Select
    'If already open, close recordset
    If m_rsIPD.State = adStateOpen Then m_rsIPD.Close
    'Execute query
    m_rsIPD.Open strQuery, g_connFSMSClient, adOpenStatic, adLockOptimistic

    Set grdIPD.DataSource = m_rsIPD
    
    If Not m_rsIPD.EOF Then
        Call SetButtons
    Else
        cmdConfirmIPD.Enabled = False
        cmdDeleteIPD.Enabled = False
    End If
    
    With grdIPD
        .ClearFields
        .ReBind
        .Columns(0).Caption = "IOR Facility"
        .Columns(1).Caption = "Cust Inv #"
        .Columns(2).Caption = "Status"
        .Columns(3).Caption = "Country"
        .Columns(4).Caption = "MAWB Trk#"
        .Columns(0).Width = "1600"
        .Columns(1).Width = "1600"
        .Columns(2).Width = "1150"
        .Columns(3).Width = "1150"
        .Columns(4).Width = "1600"
    End With
    
Release:
    Set m_rsIPD = Nothing
    Exit Sub
EH:
    MsgBox Err.Description, vbCritical, g_strErrorLocation
    Resume Release
     
End Sub
'---------------------------------------------------------------------------------------
' Module    : SetButtons
' DateTime  : 10/26/2004
' Author    : Chris Elwell
' Purpose   : Enable/disable Confirm and Delete Button
' Call from : grdIPD_Click, frmShip.EnableButtons
'---------------------------------------------------------------------------------------
'
Public Sub SetButtons()
    On Error GoTo EH
    
    'Only enable buttons if one row selected, cmdADDIPD is enable (Winsock connected), and Status is "Open"
    With grdIPD
        If .SelBookmarks.Count <> 1 Or cmdADDIPD.Enabled = False Or .Columns(2) <> "Open" Then
            cmdConfirmIPD.Enabled = False
            cmdDeleteIPD.Enabled = False
        Else
            cmdConfirmIPD.Enabled = True
            cmdDeleteIPD.Enabled = True
        End If
    End With
    
    Exit Sub
EH:
    'Do Nothing
End Sub

